package com.lmabbe.common.datasources.core;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.lmabbe.common.datasources.config.DataSourcesProperties;
import lombok.RequiredArgsConstructor;

/**
 * @author lmabbe
 */
@RequiredArgsConstructor
public class CustomIdGenerator implements IdentifierGenerator {

    private final DataSourcesProperties dataSourcesProperties;

    @Override
    public Long nextId(Object entity) {
        return IdUtil.createSnowflake(dataSourcesProperties.getTerminalId(), dataSourcesProperties.getCentreId()).nextId();
    }
}